
		<!-- MAIN -->
		<div class="main">
			<!-- MAIN CONTENT -->
			<div class="main-content">
				<div class="container-fluid">
					<h3 class="page-title">Tables</h3>
					<div class="row">
						<div class="col-md-12">
							<!-- BASIC TABLE -->
							<div class="panel">
								<div class="panel-heading">
									<h3 class="panel-title">权限列表</h3>
								</div>
								<div class="panel-body">


									<table class="table">
										<thead>
											<tr>
												<td>ID</td>
												<td>名称</td>
												<td>规则</td>
												<td>pid</td>
												<td>操作</td>
											</tr>
										</thead>
										<tbody>

										<?php foreach($data as $v) { 
										?>
											<tr level="1" pid="<?php echo $v['pid']?>">
												<td ><?php echo $v['id']?></td>
												<td class="db_edit" filed="title" width="700">

                                                 <button class="more btn" id="<?php echo $v['id']?>">+</button>
												<?php echo $v['name']?></td>

												<td><?php echo $v['role']?></td>

												<td><?php echo $v['pid']?></td>
												

												<td>
												<a href="index.php?c=cate&a=edit&admin=1&id=<?php echo $v['id']?>" class="btn btn-primary"><i class="fa lnr lnr-pencil"></i>编辑</a>
												<br>				
												<a href="index.php?c=cate&a=del&id=<?php echo $v['id']?>"    class="btn D del"><i class="Danger lnr lnr-trash"></i>删除</a>
												</td>
											</tr>
										<?php } ?>
										</tbody>
									</table>
								</div>
							</div>
							<!-- END BASIC TABLE -->
						</div>
						<div class="col-md-12">
							<!-- TABLE NO PADDING -->
							<div class="page-num">
                            <ul class="ppap"> 
                            </ul>
                            </div>
							</div>
							<!-- END CONDENSED TABLE -->
						</div>
					</div>
				</div>
			</div>
			<!-- END MAIN CONTENT -->
		</div>
		

	<script src="resources/assets/jquery-3.2.1.min.js" ></script>
	<script>

		$(function(){

           $("tbody").on('click','.more',function(){


            	
            	var obj = $(this);

            	 var tr_obj=$(this).parent().parent();

                   // 获取当前行pid属性值
            	 var pid = tr_obj.attr('pid');
                   // 获取当前对对象集合里面对应传递的对象的下标
            	  var index = $('tr[pid='+pid+']').index(tr_obj);

            	   var len = $('tr[pid='+pid+']').length-1;

                  var id=$(this).attr('id');
                 if('+'==$(this).text()){
                 	var level = parseInt(tr_obj.attr('level'));
                 	left = level*40;
                 	level++;
                 	// left+=60;
                   $(this).text('-')
                   $.ajax({

                   	type:'get',
                   	url:'index.php?c=power&a=list&admin=1&id='+id,
                   	dataType:'json',
                   	success:function(json){

                   		var html =' ';
                                for(i in json){
								 html+='<tr level="'+level+'" pid="'+id+'">';
								 html+='<td>'+json[i].id+'</td>';
								 html+='<td class="db_edit" filed="title" width="700" style="padding-left:'+left+'px">';
								 html+='<button class="more btn" id="'+json[i].id+'" >+</button>'+json[i].name+'</td>';;
								
                                  html+='<td>'+json[i].role+'</td>';
								 html+='<td>'+json[i].pid+'</td>';
	
								 html+='<td><a href="index.php?c=power&a=edit&admin=1&id='+json[i].id+'" class="btn btn-primary"><i class="fa lnr lnr-pencil"></i>编辑</a>';
								 html+='<br>';				
								 html+='<a href="index.php?c=power&a=del&id='+json[i].id+'" class="btn D del"><i class="Danger lnr lnr-trash"></i>删除</a>';
								 html+='</td>';
								 html+='</tr>';
                                    }

                                    if(len==index){

                                      html+='<tr pid="'+pid+'" style="display:none"></tr>';
                                    }
         //                            if(i==json.length-1){
         //           
								 // $(obj).parent().parent().after(html);
								  tr_obj.after(html);

								 // 获取属性值一样的的tr其标签的长度
								 
                       	}

           })

                 }else{


                   $(this).text('+');


                   var pid= tr_obj.attr('pid');


                   tr_obj.nextUntil('tr[pid='+pid+']').remove();
              
      }

   })

 })          



























			// alert(222);
			// $('.del').click(function(){

			// 	if(!confirm('确定删除？')){
			// 		return false;
			// 	}
   //                 var url = $(this).attr('href');

   //                  $.ajax({

   //                      type:'get',
   //                      url:url,
   //                      success:function(json){
   //                              if(json>0){


   //                              	if(confirm('您所删除的分类还有子级，是否继续执行操作？')){

   //                                     location.href=url;



   //                              	}




   //                              }


   //                      }



   //                 })

   //                return false;
			// })
			
	      
	

</script>